#!/bin/sh
#name:@invisible
#desc:Add agent to the network
#package:oddiscovery
#type:local

# Copyright(c) 2011 OpenDomo Services SL. Licensed under GPL v3 or later

CNF_PATH=/etc/opendomo/discovery/services
NETPASS=`cat /etc/opendomo/discovery/password`
EXECREMOTE=/usr/local/opendomo/discovery/execRemoteScript.sh

if test -z "$1"
then
	echo "#ERR No agent to remove"
else	
		if echo $1 | grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$' > /dev/null
		then
			sed -i /$1/d /home/admin/.ssh/known_hosts 2>/dev/null
			sed -i /$1/d /var/opendomo/oddiscovery-agentlist 2>/dev/null
			echo "# Agent removed"
		fi
	fi

echo
